package chapter12

/**
  * @Copyright: Shanghai Definesys Company.All rights reserved.
  * @Description:
  * @author: chuhaitao
  * @since: 2019/1/13 22:18
  * @history:
  *          1.2019/1/13 created by chuhaitao
  */
object MapDemo {

  def main(args: Array[String]): Unit = {

    //
    var list01 = List(1, 2, 3, 4, 5, 5, 6)

    var list02 = List[Int]()
    //传统的做法
    //有点 ：直接 容易理解
    //缺点： 不够简洁
    for (item <- list01) {
      list02 = list02 :+ item * 2
    }
    //传入函数，
    println("for:" + list02)
    var fm = (n: Int) => {
      n * 2
    }
    list02 = list01.map(a => a * 2) // 等价于 list02 = list01.map(fm)
    println("list02:" + list02)
    list01

   // list02 = list01.map(fm _)
  }


  def test(f: () => Unit) = {

  }


}
